#==================================================================
# Reference:
#	https://shields.io/
#	https://makefiletutorial.com/
#==================================================================

all: help


## build@构建项目
.PHONY:build
build:
	@echo "\033[33m⚙️  正在构建...\033[0m"
	@mkdir -p build && cd build && cmake .. && make -j8 && cd ..
	@echo "\033[0;31m🍩 构建成功\033[0m"


## run@运行程序
.PHONY:run
run: 
#	@{ git diff-index . --quiet HEAD -- || $(MAKE) build; }
	@cd build && ./gateway.exe && cd ..


## test@测试项目
.PHONY:test
test:
	@echo "\033[33m🧪  正在测试...\033[0m"
	@mkdir -p build && cd build && cmake.. && make test -j8 && cd..
	@echo "\033[0;31m✅ 测试成功\033[0m\n"


## clean@清理文件
.PHONY:clean
clean:
	@echo "\033[33m✈️  正在清理...\033[0m"
	@rm -rf ./bin
	@rm -rf ./build
	@rm -rf ./logs
	@rm -rf ./log
	@rm -rf ./cache
	@rm -rf ./pid
	@rm -rf ./release
	@rm -rf ./debug
	@rm -rf ./deploy
	@rm -rf ./tmp
	@rm -rf ./temp
	@rm -rf cmake_build
	@rm -rf cmake-build*
	@rm -rf ./vendor/*
	@echo "\033[31m✅ 清理完毕\033[0m\n"


## help@查看帮助
.PHONY:help
help:Makefile
	@echo "Usage:\n  make [command]"
	@echo
	@echo "Available Commands:"
	@sed -n "s/^##//p" $< | column -t -s '@' |grep --color=auto "^[[:space:]][a-zA-Z0-9_]\+[[:space:]]"
	@echo
	@echo "更多内容,请参考： https://github.com/hollson\n"
